//
//  ViewController.swift
//  研究CoreImage
//
//  Created by 崔博 on 2017/7/12.
//  Copyright © 2017年 崔博. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    typealias Filter = (CGImage) ->CIImage
    
    override func viewDidLoad() {
        super.viewDidLoad()
    
    }
    
//    func myFilter(/* parmaters */) -> Filter  (基本形态)
    func blur(radius: Double) -> Filter {
        return { image in
            let parmaters = [kCIInputRadiusKey: radius,
                             kCIInputImageKey: image
            ] as [String : Any]
            
            guard let filter = CIFilter(name: "CIGaussianBlur", withInputParameters: parmaters)
                else {fatalError()}
            guard let outpuImage = filter.outputImage else { fatalError()}
            return outpuImage;
        }
    }
}

